




IF NOT EXISTS(SELECT * FROM SYS.CHANGE_TRACKING_TABLES WHERE OBJECT_ID IN 
(SELECT OBJECT_ID FROM SYS.TABLES WHERE NAME LIKE '%Sales.Customer%'))
	BEGIN 
		ALTER TABLE Sales.Customer
		ENABLE CHANGE_TRACKING
		WITH (TRACK_COLUMNS_UPDATED = OFF)
	END
ELSE
	BEGIN
		PRINT 'Customer TABLE ALREADY CONFIGURED FOR CHANGE TRACKING'
	END
GO

IF NOT EXISTS(SELECT * FROM SYS.CHANGE_TRACKING_TABLES WHERE OBJECT_ID IN 
(SELECT OBJECT_ID FROM SYS.TABLES WHERE NAME LIKE '%Sales.CustomerContact%'))
	BEGIN 
		ALTER TABLE Sales.CustomerContact
		ENABLE CHANGE_TRACKING
		WITH (TRACK_COLUMNS_UPDATED = OFF)
	END
ELSE
	BEGIN
		PRINT 'CustomerContact TABLE ALREADY CONFIGURED FOR CHANGE TRACKING'
	END
GO

IF NOT EXISTS(SELECT * FROM SYS.CHANGE_TRACKING_TABLES WHERE OBJECT_ID IN 
(SELECT OBJECT_ID FROM SYS.TABLES WHERE NAME LIKE '%Sales.OrderDetail%'))
	BEGIN 
		ALTER TABLE Sales.OrderDetail
		ENABLE CHANGE_TRACKING
		WITH (TRACK_COLUMNS_UPDATED = OFF)
	END
ELSE
	BEGIN
		PRINT 'OrderDetail TABLE ALREADY CONFIGURED FOR CHANGE TRACKING'
	END
GO

IF NOT EXISTS(SELECT * FROM SYS.CHANGE_TRACKING_TABLES WHERE OBJECT_ID IN 
(SELECT OBJECT_ID FROM SYS.TABLES WHERE NAME LIKE '%Sales.OrderHeader%'))
	BEGIN 
		ALTER TABLE Sales.OrderHeader
		ENABLE CHANGE_TRACKING
		WITH (TRACK_COLUMNS_UPDATED = OFF)
	END
ELSE
	BEGIN
		PRINT 'OrderHeader TABLE ALREADY CONFIGURED FOR CHANGE TRACKING'
	END
GO

IF NOT EXISTS(SELECT * FROM SYS.CHANGE_TRACKING_TABLES WHERE OBJECT_ID IN 
(SELECT OBJECT_ID FROM SYS.TABLES WHERE NAME LIKE '%Sales.Vendor%'))
	BEGIN 
		ALTER TABLE Sales.Vendor
		ENABLE CHANGE_TRACKING
		WITH (TRACK_COLUMNS_UPDATED = OFF)
	END
ELSE
	BEGIN
		PRINT 'Vendor TABLE ALREADY CONFIGURED FOR CHANGE TRACKING'
	END
GO
